//
//  JJAlbumListModel.swift
//  JJAlbum
//
//  Created by 吴梓杭 on 2025/10/11.
//

import UIKit
import Photos

public class JJAlbumListModel: NSObject {
    // 相册名称
    @objc public let title: String
    
    @objc public var count: Int {
        return result.count
    }
    
    @objc public var result: PHFetchResult<PHAsset>
    
    @objc public let collection: PHAssetCollection
    
    @objc public let option: PHFetchOptions
    // 是否为主相册
    @objc public let isCameraRoll: Bool
    
    @objc public var headImageAsset: PHAsset? {
        return result.lastObject
    }
    // 相册里所有照片
    @objc public var models: [JJAssetModel] = []
    // 总数量
    @objc public var currentLoadIndex: Int
    
    @objc public init(
        title: String,
        result: PHFetchResult<PHAsset>,
        collection: PHAssetCollection,
        option: PHFetchOptions,
        isCameraRoll: Bool
    ) {
        self.title = title
        self.result = result
        self.collection = collection
        self.option = option
        self.isCameraRoll = isCameraRoll
        currentLoadIndex = result.count
    }
    
    @discardableResult
    @objc public func preloadPhotos(_ loadAll: Bool = false) -> [JJAssetModel] {
        return internal_preloadPhotos(loadAll)
    }
    

}

